import axios from "axios";
import { bar as barFn } from "./utils/bar";

const message = "hello Main";
console.log(message);

const bar = () => {
  console.log("bar");
};

bar();

barFn();

axios.get("/api/lyric?id=1842025914").then((res) => console.log(res.data));

const btn1 = document.createElement("button");
const btn2 = document.createElement("button");
btn1.textContent = "关于";
btn2.textContent = "分类";
document.body.append(btn1);
document.body.append(btn2);

btn1.onclick = async () => {
  const ret = await import(
    /* webpackChunkName:"about" */ /*webpackPrefetch: true*/ "./router/about"
  );
  console.log(ret);
  ret.bar();
  console.log(ret.default);
};

btn2.onclick = async () => {
  // 魔法注释，为chunkFilename定义name，可以用于webpack中[name]
  await import(
    /* webpackChunkName:"category" */ /*webpackPrefetch: true*/ "./router/category"
  );
};
